function ErrorCalculatorLarSTHarmonic
format long e

gauge1=load('Larx50.out');
gauge2=load('Larx100.out');
gauge3=load('Larx150.out');
gauge4=load('Larx200.out');
gauge5=load('Larx250.out');
gauge6=load('Larx300.out');
gauge7=load('Larx350.out');
gauge8=load('Larx400.out');
gauge9=load('Larx450.out');
gauge10=load('Larx500.out');
gauge11=load('Larx550.out');

datax50=[gauge1(:,1) gauge1(:,2)];
datax100=[gauge2(:,1) gauge2(:,2)];
datax150=[gauge3(:,1) gauge3(:,2)];
datax200=[gauge4(:,1) gauge4(:,2)];
datax250=[gauge5(:,1) gauge5(:,2)];
datax300=[gauge6(:,1) gauge6(:,2)];
datax350=[gauge7(:,1) gauge7(:,2)];
datax400=[gauge8(:,1) gauge8(:,2)];
datax450=[gauge9(:,1) gauge9(:,2)];
datax500=[gauge10(:,1) gauge10(:,2)];
datax550=[gauge11(:,1) gauge11(:,2)];

NNN=length(gauge1);
fftx50=fft(datax50(:,2))/NNN;
fftx100=fft(datax100(:,2))/NNN;
fftx150=fft(datax150(:,2))/NNN;
fftx200=fft(datax200(:,2))/NNN;
fftx250=fft(datax250(:,2))/NNN;
fftx300=fft(datax300(:,2))/NNN;
fftx350=fft(datax350(:,2))/NNN;
fftx400=fft(datax400(:,2))/NNN;
fftx450=fft(datax450(:,2))/NNN;
fftx500=fft(datax500(:,2))/NNN;
fftx550=fft(datax550(:,2))/NNN;
fftxAll=[fftx50,fftx100,fftx150,fftx200,fftx250,fftx300,fftx350,fftx400,fftx450,fftx500,fftx550]';

ZeroModeLoc=157;
NumModes=39;
% The following k0 value includes surface tension.
k0=1.52759556257556977;
epsilon=2*k0*abs(fftx50(ZeroModeLoc));

ExptGauges=abs(fftxAll(:,ZeroModeLoc-NumModes:ZeroModeLoc+NumModes));
[MMM,JJJ]=size(ExptGauges);

NLSSTHarmonicAlldata=epsilon/k0*load('NLSSTHarmonicAlldata.out');
dNLSSTHarmonicAlldata=epsilon/k0*load('dNLSSTHarmonicAlldata.out');
DystheSTHarmonicAlldata=epsilon/k0*load('DystheSTHarmonicAlldata.out');
vDystheSTHarmonicAlldata=epsilon/k0*load('vDystheSTHarmonicAlldata.out');
dGTSTHarmonicAlldata=epsilon/k0*load('dGTSTHarmonicAlldata.out');
NLSSTHarmonicGauges=NLSSTHarmonicAlldata(1:500:5001,:);
dNLSSTHarmonicGauges=dNLSSTHarmonicAlldata(1:500:5001,:);
DystheSTHarmonicGauges=DystheSTHarmonicAlldata(1:500:5001,:);
vDystheSTHarmonicGauges=vDystheSTHarmonicAlldata(1:500:5001,:);
dGTSTHarmonicGauges=dGTSTHarmonicAlldata(1:500:5001,:);

HannahNLSSTHarmonicError=100/JJJ/(MMM-1)*sum(sum((ExptGauges'-NLSSTHarmonicGauges').^2)./sum((abs(ExptGauges')).^2))
HannahdNLSSTHarmonicError=100/JJJ/(MMM-1)*sum(sum((ExptGauges'-dNLSSTHarmonicGauges').^2)./sum((abs(ExptGauges')).^2))
HannahDystheSTHarmonicError=100/JJJ/(MMM-1)*sum(sum((ExptGauges'-DystheSTHarmonicGauges').^2)./sum((abs(ExptGauges')).^2))
HannahvDystheSTHarmonicError=100/JJJ/(MMM-1)*sum(sum((ExptGauges'-vDystheSTHarmonicGauges').^2)./sum((abs(ExptGauges')).^2))
HannahdGTSTHarmonicError=100/JJJ/(MMM-1)*sum(sum((ExptGauges'-dGTSTHarmonicGauges').^2)./sum((abs(ExptGauges')).^2))

u1p=4;
u2p=8;
u3p=12;
l1m=4;
l2m=8;
l3m=12;

a0s=abs(fftxAll(:,ZeroModeLoc));
an1s=abs(fftxAll(:,ZeroModeLoc-l1m));
a1s=abs(fftxAll(:,ZeroModeLoc+u1p));
an2s=abs(fftxAll(:,ZeroModeLoc-l2m));
a2s=abs(fftxAll(:,ZeroModeLoc+u2p));
an3s=abs(fftxAll(:,ZeroModeLoc-l3m));
a3s=abs(fftxAll(:,ZeroModeLoc+u3p));

carrier=(JJJ+1)/2;
u1=carrier+u1p;
u2=carrier+u2p;
u3=carrier+u3p;
l1=carrier-l1m;
l2=carrier-l2m;
l3=carrier-l3m;

NLSSTHarmoniccarrier=NLSSTHarmonicAlldata(1:100:end,carrier);
dNLSSTHarmoniccarrier=dNLSSTHarmonicAlldata(1:100:end,carrier);
DystheSTHarmoniccarrier=DystheSTHarmonicAlldata(1:100:end,carrier);
vDystheSTHarmoniccarrier=vDystheSTHarmonicAlldata(1:100:end,carrier);
dGTSTHarmoniccarrier=dGTSTHarmonicAlldata(1:100:end,carrier);
NLSu1=NLSSTHarmonicAlldata(1:100:end,u1);
dNLSu1=dNLSSTHarmonicAlldata(1:100:end,u1);
Dystheu1=DystheSTHarmonicAlldata(1:100:end,u1);
vDystheu1=vDystheSTHarmonicAlldata(1:100:end,u1);
dGTSTHarmonicu1=dGTSTHarmonicAlldata(1:100:end,u1);
NLSu2=NLSSTHarmonicAlldata(1:100:end,u2);
dNLSu2=dNLSSTHarmonicAlldata(1:100:end,u2);
Dystheu2=DystheSTHarmonicAlldata(1:100:end,u2);
vDystheu2=vDystheSTHarmonicAlldata(1:100:end,u2);
dGTSTHarmonicu2=dGTSTHarmonicAlldata(1:100:end,u2);
NLSu3=NLSSTHarmonicAlldata(1:100:end,u3);
dNLSu3=dNLSSTHarmonicAlldata(1:100:end,u3);
Dystheu3=DystheSTHarmonicAlldata(1:100:end,u3);
vDystheu3=vDystheSTHarmonicAlldata(1:100:end,u3);
dGTSTHarmonicu3=dGTSTHarmonicAlldata(1:100:end,u3);

NLSl1=NLSSTHarmonicAlldata(1:100:end,l1);
dNLSl1=dNLSSTHarmonicAlldata(1:100:end,l1);
Dysthel1=DystheSTHarmonicAlldata(1:100:end,l1);
vDysthel1=vDystheSTHarmonicAlldata(1:100:end,l1);
dGTSTHarmonicl1=dGTSTHarmonicAlldata(1:100:end,l1);
NLSl2=NLSSTHarmonicAlldata(1:100:end,l2);
dNLSl2=dNLSSTHarmonicAlldata(1:100:end,l2);
Dysthel2=DystheSTHarmonicAlldata(1:100:end,l2);
vDysthel2=vDystheSTHarmonicAlldata(1:100:end,l2);
dGTSTHarmonicl2=dGTSTHarmonicAlldata(1:100:end,l2);
NLSl3=NLSSTHarmonicAlldata(1:100:end,l3);
dNLSl3=dNLSSTHarmonicAlldata(1:100:end,l3);
Dysthel3=DystheSTHarmonicAlldata(1:100:end,l3);
vDysthel3=vDystheSTHarmonicAlldata(1:100:end,l3);
dGTSTHarmonicl3=dGTSTHarmonicAlldata(1:100:end,l3);

positions=[0,50,100,150,200,250,300,350,400,450,500]';
x=0:1/10:5000/10;
x=x(1:100:end);

figure(6)
subplot(4,2,[1,2])
hold off
scatter(positions,a0s,'filled','k')
hold on
plot(x,NLSSTHarmoniccarrier,'k')
plot(x,DystheSTHarmoniccarrier,'k--')
l=legend('data','NLS','Dysthe','Location','SouthWest','Orientation','horizontal');
l.NumColumns=2;
ylabel('$|a_0|$','Interpreter','Latex')
title('Expt B Second Harmonic')
axis tight
subplot(4,2,3)
hold off
scatter(positions,an1s,'filled','k')
hold on
plot(x,NLSl1,'k')
plot(x,Dysthel1,'k--')
ylabel('$|a_{-4}|$','Interpreter','Latex')
xlim([0 x(end)])
ylim([0 0.005])
subplot(4,2,4)
hold off
scatter(positions,a1s,'filled','k')
hold on
plot(x,NLSu1,'k')
plot(x,Dystheu1,'k--')
ylabel('$|a_3|$','Interpreter','Latex')
xlim([0 x(end)])
ylim([0 0.005])
subplot(4,2,5)
hold off
scatter(positions,an2s,'filled','k')
hold on
plot(x,NLSl2,'k')
plot(x,Dysthel2,'k--')
ylabel('$|a_{-8}|$','Interpreter','Latex')
xlim([0 x(end)])
ylim([0 0.003])
subplot(4,2,6)
hold off
scatter(positions,a2s,'filled','k')
hold on
plot(x,NLSu2,'k')
plot(x,Dystheu2,'k--')
ylabel('$|a_8|$','Interpreter','Latex')
xlim([0 x(end)])
ylim([0 0.003])
subplot(4,2,7)
hold off
scatter(positions,an3s,'filled','k')
hold on
plot(x,NLSl3,'k')
plot(x,Dysthel3,'k--')
xlabel('$x$ (cm)','Interpreter','Latex')
ylabel('$|a_{-12}|$','Interpreter','Latex')
xlim([0 x(end)])
ylim([0 0.003])
subplot(4,2,8)
hold off
scatter(positions,a3s,'filled','k')
hold on
plot(x,NLSu3,'k')
plot(x,Dystheu3,'k--')
xlabel('$x$ (cm)','Interpreter','Latex')
ylabel('$|a_{12}|$','Interpreter','Latex')
xlim([0 x(end)])
ylim([0 0.003])



figure(66)
subplot(4,2,[1,2])
hold off
scatter(positions,a0s,'filled','k')
hold on
plot(x,dNLSSTHarmoniccarrier,'k')
plot(x,vDystheSTHarmoniccarrier,'k--')
plot(x,dGTSTHarmoniccarrier,'k-.')
l=legend('data','dNLS','vDysthe','dGT','Location','SouthWest','Orientation','horizontal');
l.NumColumns=2;
ylabel('$|a_0|$','Interpreter','Latex')
title('Expt B Second Harmonic')
axis tight
subplot(4,2,3)
hold off
scatter(positions,an1s,'filled','k')
hold on
plot(x,dNLSl1,'k')
plot(x,vDysthel1,'k--')
plot(x,dGTSTHarmonicl1,'k-.')
ylabel('$|a_{-4}|$','Interpreter','Latex')
xlim([0 x(end)])
ylim([0 0.005])
subplot(4,2,4)
hold off
scatter(positions,a1s,'filled','k')
hold on
plot(x,dNLSu1,'k')
plot(x,vDystheu1,'k--')
plot(x,dGTSTHarmonicu1,'k-.')
ylabel('$|a_4|$','Interpreter','Latex')
xlim([0 x(end)])
ylim([0 0.005])
subplot(4,2,5)
hold off
scatter(positions,an2s,'filled','k')
hold on
plot(x,dNLSl2,'k')
plot(x,vDysthel2,'k--')
plot(x,dGTSTHarmonicl2,'k-.')
ylabel('$|a_{-8}|$','Interpreter','Latex')
xlim([0 x(end)])
ylim([0 0.003])
subplot(4,2,6)
hold off
scatter(positions,a2s,'filled','k')
hold on
plot(x,dNLSu2,'k')
plot(x,vDystheu2,'k--')
plot(x,dGTSTHarmonicu2,'k-.')
ylabel('$|a_8|$','Interpreter','Latex')
xlim([0 x(end)])
ylim([0 0.003])
subplot(4,2,7)
hold off
scatter(positions,an3s,'filled','k')
hold on
plot(x,dNLSl3,'k')
plot(x,vDysthel3,'k--')
plot(x,dGTSTHarmonicl3,'k-.')
xlabel('$x$ (cm)','Interpreter','Latex')
ylabel('$|a_{-12}|$','Interpreter','Latex')
xlim([0 x(end)])
ylim([0 0.003])
subplot(4,2,8)
hold off
scatter(positions,a3s,'filled','k')
hold on
plot(x,dNLSu3,'k')
plot(x,vDystheu3,'k--')
plot(x,dGTSTHarmonicu3,'k-.')
xlabel('$x$ (cm)','Interpreter','Latex')
ylabel('$|a_{12}|$','Interpreter','Latex')
xlim([0 x(end)])
ylim([0 0.003])
